package org.popupcommunication.dao.impl;

import java.util.List;

import javax.persistence.TypedQuery;

import org.popupcommunication.dao.AgendaGroupeDAO;
import org.popupcommunication.model.AgendaGroupe;
import org.popupcommunication.model.Group;

public class AgendaGroupeJpa extends GenericRepositoryJpa<AgendaGroupe> implements AgendaGroupeDAO {

	@Override
	public List<AgendaGroupe> getEventByGroup(Group grp) {
		TypedQuery<AgendaGroupe> query =  this.getEntityManager().createQuery("SELECT a FROM AgendaGroupe a where a.groupe=:grp order by a.dateDebut", AgendaGroupe.class);
		query.setParameter("grp", grp);
		List<AgendaGroupe> results = query.getResultList();
		return results;
	}

	@Override
	public List<AgendaGroupe> getAllEvents() {
		TypedQuery<AgendaGroupe> query =  this.getEntityManager().createQuery("SELECT a FROM AgendaGroupe a order by a.dateDebut", AgendaGroupe.class);
		List<AgendaGroupe> results = query.getResultList();
		return results;
	}

}
